/**
 * Created by yu on 16/9/1.
 */

var http = require('http');
var url = require('url');
var fs = require('fs');
var queryString = require('querystring');
var server = http.createServer(function(req,res){
    var urlObj = url.parse(req.url,true);
    if(urlObj.pathname == '/'){
        res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
        fs.readFile('./index.html','utf-8',function(err,data){
            res.end(data);
        })
    }else if(urlObj.pathname == '/data'){
        var str = '';
        req.on('data',function(data){
            str += data.toString();
        })
        req.on('end',function(){

            res.end(str);
        })
    }
});

server.listen('8080','localhost');
